//
// Created by dong on 2025/10/20.
//

#ifndef BASEC_SWIDGET_H
#define BASEC_SWIDGET_H

/***
 * 控件的超级父类
 *
 */
#include "Sobj.h"

struct SwidgetData
{
    SwidgetData();
    int x;
    int y;
    int w;
    int h;
    SDL_Color bkColor;
    SDL_Color textColor;
    SDL_Color curColor;

    bool isVisible;
    bool isFocus;

    string title;
};

class Swidget:public Sobj
{
public:
    Swidget(Swidget* parent=nullptr);
    virtual ~Swidget();
    virtual bool event(SDL_Event* msg);

public:

    void settextcolor(const SDL_Color& color);
    void setbkcolor(const SDL_Color& color);
    void setpos(int x,int y);
    void setpos(int x,int y,int w,int h);
    void setvisible(bool visible);
    void setfocus(bool focus);

    bool getvisible();
public:
    //判断一个点十分在控件上
    bool contains(int x,int y);

public:
    virtual void paintEvent(SDL_Event* msg);
    virtual void mousePressEvent(SDL_Event* msg);
    virtual void mouseReleaseEvent(SDL_Event* msg);
    virtual void mouseMoveEvent(SDL_Event* msg);
    virtual void inputEvent(SDL_Event* msg);
    virtual void editEvent(SDL_Event* msg);
    virtual void keyDownEvent(SDL_Event* msg);
protected:
    SwidgetData* m_data;
};



#endif //BASEC_SWIDGET_H